package test.coin;

import java.math.BigInteger;
import java.util.concurrent.ExecutionException;

import org.web3j.protocol.core.methods.response.Transaction;

import com.alibaba.fastjson.JSON;


public class erc20tokentrade {
	
	public static void main(String[ ]arg) {
		// test转出eth() ;
		test查询单笔交易明细();
	}
	public static void test转出代币() {
		String 转给谁="0x14d361455d5ddb6c68cd3071de5169cc4ce535f0";
		BigInteger 转出数量=new BigInteger("1000000000000000000");
		transferERC20Token(转给谁,转出数量);
		System.out.println("执行完成");
	}
	public static void test转出eth() {
		String 转给谁="0x14d361455d5ddb6c68cd3071de5169cc4ce535f0";
		BigInteger 转出数量=new BigInteger("100000000000000000");
		transferETH(转给谁,转出数量);
		System.out.println("执行完成");
	}
	public static void test查询单笔交易明细() {
		String txhash="0x18673ceaec7423862181ac7aba1cd0d6cf30c0e90e18566a8cd64c8a59e41c3d";
		Transaction t=Erc20api.getTransactionByHash(txhash);
		System.out.println(JSON.toJSONString(t));	
	} 
	static String 转出人="0xf6fb9788e2c633047aabf3dd0b9e4574d4383b53";		
	static String 合约地址="0x3981569c3020f3afef02c751c11556f235d97a7d";
	static String 转出人密钥="a1b783bf1fedcbcb0e47fd1833a7040204eb32c66a8c9a94ebd858a9713e851b";
	
	/**
    * @param 转入人 收账账号
    * @param 转出数量 额度
    */
   public static void transferERC20Token(String 转入人, BigInteger 转出数量) {		
		try {
			Erc20api.transferERC20Token(合约地址,转出人,转出人密钥,转入人,转出数量);
		} catch (InterruptedException|ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
   }
   /**
    * @param 转入人 收账账号
    * @param 转出数量 额度
    */
   public static void transferETH(String 转入人, BigInteger 转出数量)  {		
		try {
			Erc20api.transferETH(转出人,转出人密钥,转入人,转出数量);
		} catch (InterruptedException|ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
   }
  
 
}